package com.base.cn.platform.os.service.course.cou.record;

import com.base.cn.platform.os.common.j2cache.CustomCacheChannel;
import com.base.cn.platform.os.common.mybatis.BaseBiz;
import com.base.cn.platform.os.common.mybatis.Pagination;
import com.base.cn.platform.os.common.mybatis.table.CreateTableTool;
import com.base.cn.platform.os.common.utils.DataUtil;
import com.base.cn.platform.os.common.utils.DateUtils;
import com.base.cn.platform.os.common.utils.ObjectUtils;
import com.base.cn.platform.os.common.utils.StringUtils;
import com.base.cn.platform.os.common.utils.course.CourseType;
import com.base.cn.platform.os.dao.course.cou.record.CourseLearnFlowDao;
import com.base.cn.platform.os.entity.course.catalog.CourseCatalog;
import com.base.cn.platform.os.entity.course.cou.Course;
import com.base.cn.platform.os.entity.course.cou.record.CourseLearnFlow;
import com.base.cn.platform.os.entity.course.cou.record.CoursePlayRecord;
import com.base.cn.platform.os.entity.course.material.CouMaterial;
import com.base.cn.platform.os.entity.exam.record.ExamRecord;
import com.base.cn.platform.os.service.course.catalog.CourseCatalogBiz;
import com.base.cn.platform.os.service.course.cou.CourseBiz;
import com.base.cn.platform.os.service.course.material.CouMaterialBiz;
import com.base.cn.platform.os.service.exam.record.ExamRecordService;
import com.base.cn.platform.os.service.manage.user.user.CusUserService;
import com.base.cn.platform.os.service.manage.user.user.SetUserDataService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.sql.DataSource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;


/**
 * @author ZJh
 * @since 2018-12-14
 **/
@Service
public class CourseLearnFlowBiz extends BaseBiz<CourseLearnFlow, CourseLearnFlowDao> {
    @Autowired
    private CourseBiz courseBiz;
    @Autowired
    private CourseCatalogBiz courseCatalogBiz;
    @Autowired
    private CouMaterialBiz couMaterialBiz;
    @Autowired
    private CourseLearnFlowDao courseLearnFlowDao;
    @Autowired
    private CoursePlayRecordBiz coursePlayRecordBiz;
    @Autowired
    private  CusUserService cusUserService;
    @Autowired
    private DataSource dataSource;
    @Autowired
    private SetUserDataService<CourseLearnFlow> setUserDataService;
    @Autowired
    private ExamRecordService  examRecordService;
    @Autowired
    private CustomCacheChannel customCacheChannel;

    /**
     * 保存课程播放记录更新学习记录
     *
     * @param courseLearnFlow 课程学习记录明细
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveFlowAndUpdateRecord(CourseLearnFlow courseLearnFlow,Integer finish) {
            courseLearnFlow.setFinish(finish);
         //  try{
                 this.saveCourseLearnFlow(courseLearnFlow);
          /* }catch (Exception e){
               if(e.getMessage().contains("doesn't exist")){
                   tableError(ShardingConstant.COURSE_LEARN_FLOW_TB_NAME,courseLearnFlow.getUserId().toString());
                   this.saveCourseLearnFlow(courseLearnFlow);
               }
            }*/

            CoursePlayRecord userCatalogPlayRecord = coursePlayRecordBiz.findUserCatalogPlayRecord(courseLearnFlow.getUserId(), courseLearnFlow.getBuyCourseId(), courseLearnFlow.getCourseId(), courseLearnFlow.getCatalogId());
            CoursePlayRecord catalogPlayRecord =   new CoursePlayRecord();
            if(ObjectUtils.isNotEmpty(userCatalogPlayRecord)){
                catalogPlayRecord.setUserId(courseLearnFlow.getUserId());
                catalogPlayRecord.setId(userCatalogPlayRecord.getId());
                catalogPlayRecord.setSource(courseLearnFlow.getSource());
                catalogPlayRecord.setDuration(courseLearnFlow.getDuration());
                catalogPlayRecord.setMaxDuration(courseLearnFlow.getDuration() > userCatalogPlayRecord.getMaxDuration()?courseLearnFlow.getDuration():userCatalogPlayRecord.getMaxDuration());
                catalogPlayRecord.setDurationCatalogNum((ObjectUtils.isNotEmpty(userCatalogPlayRecord.getDurationCatalogNum())?userCatalogPlayRecord.getDurationCatalogNum():0)+courseLearnFlow.getDuration());
                catalogPlayRecord.setPlayNumber((ObjectUtils.isNotEmpty(userCatalogPlayRecord.getPlayNumber())?userCatalogPlayRecord.getPlayNumber():0)+1);
                if(userCatalogPlayRecord.getFinish()!=2){
                    catalogPlayRecord.setFinish(finish);
                }
                StringBuilder sql = new StringBuilder("id =");
                sql.append(catalogPlayRecord.getId());
                sql.append(" and userId = ");
                sql.append(courseLearnFlow.getUserId());
                coursePlayRecordBiz.updateByWhereSql(catalogPlayRecord,sql.toString());
            }else{
                catalogPlayRecord.setUserId(courseLearnFlow.getUserId());
                catalogPlayRecord.setBuyCourseId(courseLearnFlow.getBuyCourseId());
                catalogPlayRecord.setCourseId(courseLearnFlow.getCourseId());
                catalogPlayRecord.setCatalogId(courseLearnFlow.getCatalogId());
                catalogPlayRecord.setDuration(courseLearnFlow.getDuration());
                catalogPlayRecord.setMaxDuration(courseLearnFlow.getDuration());
                catalogPlayRecord.setDurationCatalogNum(courseLearnFlow.getDuration());
                catalogPlayRecord.setSource(courseLearnFlow.getSource());
                catalogPlayRecord.setPlayNumber(1);
                catalogPlayRecord.setFinish(finish);
               // try{
                    coursePlayRecordBiz.save(catalogPlayRecord);
               /* }catch (Exception e){
                    if(e.getMessage().contains("doesn't exist")){
                        tableError(ShardingConstant.COURSE_PLAY_RECORD_TB_NAME,courseLearnFlow.getUserId().toString());
                        coursePlayRecordBiz.save(catalogPlayRecord);
                    }
                }*/
                cusUserService.updateUserNumberOfStatistics(courseLearnFlow.getUserId(),"joinLiveCount",1);
            }
        cusUserService.updateUserNumberOfStatistics(courseLearnFlow.getUserId(),"studyTotalTime",courseLearnFlow.getDuration());

    }


    /**
     * 保存课程学习记录明细
     *
     * @param courseLearnFlow 课程学习记录
     */
    public void saveCourseLearnFlow(CourseLearnFlow courseLearnFlow) {
      this.save(courseLearnFlow);
    }

    /**
     * 查询课程章节播放次数
     *
     * @param  condition  查询条件
     */
    public Map<String,Object> selectNumAndCombined(CourseLearnFlow condition) {

        return courseLearnFlowDao.selectNumAndCombined(CourseLearnFlow.class,condition);
    }

    /**
     * 查询课程播放记录列表
     *
     * @param condition  课程播放记录查询条件
     * @return 课程播放记录列表
     */
    public PageInfo<CourseLearnFlow> queryCoursePlayDetailPage(CourseLearnFlow condition, Pagination pagination, boolean setCourse,
                                                               boolean setCatalogData) {
        condition.setOrderType(1);
        String where = this.where(condition);
        PageInfo<CourseLearnFlow> pageInfo = findPage(where, pagination, null);
        setCoursePlayRecordCourse(pageInfo.getList(),setCourse);
        setCoursePlayRecordCatalog(pageInfo.getList(),setCatalogData,false);
        return pageInfo;
    }

    /**
     * 查询某个时间点用户的学习记录（用于生成折线图）
     *
     * @param condition  课程播放记录查询条件
     * @return 课程播放记录列表
     */
    public List<Map<String,Object>> selectLearnTimeMap(CourseLearnFlow condition) {
        List<Map<String,Object>> list = null;
       // try{
            list = courseLearnFlowDao.selectLearnTimeMap(CourseLearnFlow.class,condition);
       /* }catch (Exception e){
            if(e.getMessage().contains("doesn't exist")){
                tableError(ShardingConstant.COURSE_LEARN_FLOW_TB_NAME,condition.getUserId().toString());
                list  =new ArrayList<>();
                return list;
            }
        }*/

        return  list;
    }


    /**
     * 查询用户某天的学习时间
     *
     * @param condition  课程播放记录明细查询条件
     * @return
     */
    public Integer selectOneDayTime(CourseLearnFlow condition) {

        return  courseLearnFlowDao.selectOneDayTime(CourseLearnFlow.class,condition);
    }

    /**
     * 查询课程播放记录列表
     *
     * @param condition  课程播放记录查询条件
     * @param setCourse  设置课程
     * @param setCreator 设置前台用户
     * @param setCatalogData 设置目录数据
     * @return 课程播放记录列表
     */
    public PageInfo<CourseLearnFlow> findCoursePlayRecordFlowPage(CourseLearnFlow condition, Pagination pagination,
                                                               boolean setCourse, boolean setCreator,
                                                               boolean setCatalogData,boolean setCatalogTeacher) {
        condition.setOrderType(1);
        String where = this.where(condition);
        PageInfo<CourseLearnFlow> pageInfo = null;
        /*try{*/
            pageInfo = findPage(where, pagination, null);
        /*}catch (Exception e){
            if(e.getMessage().contains("doesn't exist")){
                tableError(ShardingConstant.COURSE_LEARN_FLOW_TB_NAME,condition.getUserId().toString());
                pageInfo = new PageInfo<>();
                return pageInfo;
            }
        }*/
        //设置学员用户对象
        setUserDataService.setUserData(pageInfo.getList(), setCreator);
        //设置播放记录课程
        this.setCoursePlayRecordCourse(pageInfo.getList(), setCourse);
        //设置课程目录
        this.setCoursePlayRecordCatalog(pageInfo.getList(),setCatalogData,setCatalogTeacher);
        //设置该章节是否有随堂练习
       this.setPractice(pageInfo.getList());
        //设置时间轴
        List<CourseLearnFlow> coursePlayRecordList = this.handlingTimeAxis(pageInfo.getList());
        //处理好时间轴后，重新设置数据
        pageInfo.setList(coursePlayRecordList);
        return pageInfo;
    }


    /**
     * 查询课程播放记录列表
     *
     * @param condition  课程播放记录查询条件
     * @return 课程播放记录列表
     */
    public Map findCoursePlayRecordPracticeFlowPage(CourseLearnFlow condition, int currentPage,int pageSize) {


        //获取关于这个课程的随堂练习记录
        Map  parameter = new HashMap();
        parameter.put("userId",condition.getUserId());
        parameter.put("selectCourseIdsIn",condition.getBuyCourseId());
        parameter.put("order",5);
        parameter.put("status",2);
        parameter.put("useType",3);
        Map examRecordListPage = examRecordService.findExamRecordListPage(parameter, currentPage, pageSize);
        List<Map<String,Object>> examRecordList = (List<Map<String, Object>>) examRecordListPage.get("list");
        if(ObjectUtils.isNotEmpty(examRecordList)&&examRecordList.size()>0){
            String courseCatalogIds = examRecordList.stream().map(e -> e.get("catalogId").toString()).collect(Collectors.joining(","));
            ArrayList<String> containColumns  = new ArrayList<>();
            containColumns.add("courseId");
            containColumns.add("id");
            containColumns.add("catalogName");
            containColumns.add("questionIds");
            containColumns.add("practice");
            List<CourseCatalog> courseCatalogs = courseCatalogBiz.find("questionIds is not null and id in(" + courseCatalogIds + ")", null, containColumns);
            containColumns  = new ArrayList<>();
            containColumns.add("id");
            containColumns.add("courseName");
            containColumns.add("scorePercent");
            containColumns.add("courseTypeKey");
            Course course = courseBiz.findById(condition.getBuyCourseId(), containColumns);
            if(course.getCourseTypeKey().equals(CourseType.COURSE_TYPE_PACKAGE.getKey())){
                String courseIds = courseCatalogs.stream().map(e -> e.getCourseId().toString()).distinct().collect(Collectors.joining(","));
                List<Course> courses = courseBiz.find("id in (" + courseIds + ")", null, containColumns);
                for(CourseCatalog courseCatalog:courseCatalogs){
                    for(Course entity:courses){
                        if(courseCatalog.getCourseId().compareTo(entity.getId())==0){
                            courseCatalog.setCourse(entity);
                        }
                    }
                }
            }
            for(Map entity:examRecordList){
                entity.put("course",course);
                for (CourseCatalog catalog:courseCatalogs){
                    if(new BigDecimal(entity.get("catalogId").toString()).compareTo(catalog.getId())==0){
                        entity.put("catalog",catalog);
                        //计算是否通过随堂练习
                        //学员得分
                        int _practice =      Integer.valueOf(entity.get("userScore").toString());
                        //总分值
                        int practice = Integer.valueOf(entity.get("score").toString());
                        double scorePercent =0.0;
                        if(course.getCourseTypeKey().equals(CourseType.COURSE_TYPE_PACKAGE.getKey())){
                            scorePercent = catalog.getCourse().getScorePercent();
                        }else{
                            scorePercent =   course.getScorePercent();
                        }
                        //设置得分率
                        entity.put("scorePercent",scorePercent);
                        double _scorePercent =  new Double(_practice) / new Double(practice) * 100D;
                        //如果通过
                        if(_scorePercent>= scorePercent){
                            entity.put("pass",true);
                        }else{
                            entity.put("pass",false);
                        }
                    }
                }
            }

            if(ObjectUtils.isNotEmpty(examRecordList)){
                Map<String,List<Map>> coursePlayRecordListMap = examRecordList.stream().collect(Collectors.groupingBy(e-> e.get("updateTime").toString().substring(0,4)));
                List<Map> _list = new ArrayList<>();
                coursePlayRecordListMap.forEach((k,v)->{
                    v.get(0).put("timeAxis",k);
                    _list.addAll(v);
                });
                examRecordListPage.put("list",_list);
            }

        }


        return  examRecordListPage;
    }



    /**
     * 查询用户的学习记录（用于生成折线图）
     *
     * @param condition  时间条件 {type 1 日 2 月 3 年 startTime 开始时间 endTime结束时间}
     * @return 课程播放记录列表
     */
    public List<Map> selectLearningTrend(Map condition) {
        List<Map<String, Object>> maps = courseLearnFlowDao.selectLearningTrend(CourseLearnFlow.class, condition);
        //连续日期补全


        List<Map> data = new ArrayList<>();
        if( Integer.valueOf(condition.get("type").toString())==1){
            List<Date> dayList = DateUtils.getDayList(DateUtils.parseDate(condition.get("startTime").toString().substring(0,10), "yyyy-MM-dd"),DateUtils.parseDate(condition.get("endTime").toString().substring(0,10), "yyyy-MM-dd"));
            for(Date date:dayList){
                String format ="";
                format =  DateUtils.format(date, "yyyy-MM-dd");

                Map<String, Object> objectObjectHashMap = new HashMap<>();
                objectObjectHashMap.put("time",format);
                objectObjectHashMap.put("learntime",0);
                for(Map entity:maps){
                    if(entity.get("time").equals(format)){
                        objectObjectHashMap.put("time",format);
                        objectObjectHashMap.put("learntime",entity.get("learntime"));
                    }
                }
                data.add(objectObjectHashMap);
            }

        }else if(Integer.valueOf(condition.get("type").toString())==2){
            String startTime = condition.get("startTime").toString().substring(0, 4);

            for(int i =1;i<=12;i++){
               String format =startTime+"-"+ String.format("%02d",i);
                Map<String, Object> objectObjectHashMap = new HashMap<>();
                objectObjectHashMap.put("time",format);
                objectObjectHashMap.put("learntime",0);
                for(Map entity:maps){
                    if(entity.get("time").equals(format)){
                        objectObjectHashMap.put("learntime",entity.get("learntime"));
                    }
                }
                data.add(objectObjectHashMap);
            }


        }else{
           // format =  DateUtils.format(date, "yyyy");
        }


        return data;

    }

//==================================================私有方法=======================================================//
    /**
     * 拼接where子句
     *
     * @param condition 课程播放记录
     * @return where子句
     */
    private String where(CourseLearnFlow condition) {
        StringBuilder where = new StringBuilder(" 1 = 1");
        if(DataUtil.idIsNotNull(condition.getBuyCourseId())){
            where .append(" and buyCourseId = ").append(condition.getBuyCourseId());
        }
        if (DataUtil.idIsNotNull(condition.getCourseId())) {
            where .append( " and courseId = ").append(condition.getCourseId());
        }
        if (DataUtil.idIsNotNull(condition.getCatalogId())) {
            where .append( " and catalogId = ").append(condition.getCatalogId());
        }
        if (DataUtil.idIsNotNull(condition.getUserId())) {
            where .append( " and userId = ").append(condition.getUserId());
        }
        if (DataUtil.isPositive(condition.getSource())) {
            where .append( " and source = ").append(condition.getSource());
        }
        if(StringUtils.isNotEmpty(condition.getSelectCatalogIn())){
            where .append(" and catalogId in (").append(condition.getSelectCatalogIn()).append(")");
        }
        if(ObjectUtils.isNotEmpty(condition.getBeginCreateTime())) {
            String playDate = DateUtils.format(condition.getBeginCreateTime(), "yyyy-MM-dd HH:mm:ss");
            where .append( " and createTime >= '" ).append(playDate).append( "'");
        }
        if(ObjectUtils.isNotEmpty(condition.getEndCreateTime())) {
            String playDate = DateUtils.format(condition.getEndCreateTime(), "yyyy-MM-dd HH:mm:ss");
            where .append( " and createTime <= '" ).append(playDate).append( "'");
        }
        if(ObjectUtils.isNotEmpty(condition.getCreateTime())) {
            String playDate = DateUtils.format(condition.getCreateTime(), "yyyy-MM-dd");
            where .append( " and createTime > '" ).append(playDate).append( "'");
        }
        if(condition.getOrderType() == 1){
            where .append(" order by updateTime desc");
        }
        return where.toString();
    }


    /**
     * 设置播放记录课程
     *
     * @param courseLearnFlowList 课程播放记录
     * @param setCourse            设置课程
     */
    private void setCoursePlayRecordCourse(List<CourseLearnFlow> courseLearnFlowList, boolean setCourse) {
        if (setCourse && ObjectUtils.isNotEmpty(courseLearnFlowList)) {
            Set<BigDecimal> idSet = new HashSet<>();
            courseLearnFlowList.forEach(e->{
                if(DataUtil.idIsNotNull(e.getBuyCourseId())){
                    idSet.add(e.getBuyCourseId());
                }
                if(DataUtil.idIsNotNull(e.getCourseId())){
                    idSet.add(e.getCourseId());
                }
            });
            if(ObjectUtils.isNotEmpty(idSet)){
                String courseIds = DataUtil.joining(idSet, BigDecimal::toString);
                Map<BigDecimal, Course> courseMap = courseBiz.findCourseToMapByIds(courseIds, false, false, false, false);
                courseLearnFlowList.forEach((v) ->{
                    v.setBuyCourse(courseMap.get(v.getBuyCourseId()));
                    if(v.getBuyCourseId().compareTo(v.getCourseId()) != 0){
                        v.setCourse(courseMap.get(v.getCourseId()));
                    }
                });
            }
        }
    }
    /**
     * 处理播放记录时间轴
     * @param coursePlayRecordList 播放记录
     */
    private List<CourseLearnFlow> handlingTimeAxis(List<CourseLearnFlow> coursePlayRecordList){
        if(ObjectUtils.isNotEmpty(coursePlayRecordList)){
            Map<String,List<CourseLearnFlow>> coursePlayRecordListMap = coursePlayRecordList.stream().collect(Collectors.groupingBy(e->DateUtils.format(e.getUpdateTime(),"yyyy")));
            List<CourseLearnFlow> _list = new ArrayList<>();
            coursePlayRecordListMap.forEach((k,v)->{
                v.get(0).setTimeAxis(k);
                _list.addAll(v);
            });
            return _list;
        }
        return coursePlayRecordList;
    }
    /**
     * 设置播放记录目录数据
     * @param courseLearnFlowList 播放记录列表
     * @param setCatalogData 设置目录数据
     */
    private void setCoursePlayRecordCatalog(List<CourseLearnFlow> courseLearnFlowList,boolean setCatalogData,boolean setCatalogTeacher){
        if(ObjectUtils.isNotEmpty(courseLearnFlowList) && setCatalogData){
            String catalogIds = courseLearnFlowList.stream().map(e->e.getCatalogId().toString()).collect(Collectors.joining(","));
            Map<BigDecimal, CourseCatalog> courseCatalogMap = courseCatalogBiz.findCourseCatalogMapByIds(catalogIds,false,false,false,false);
            if(ObjectUtils.isNotEmpty(courseCatalogMap)){
                StringJoiner joiner = new StringJoiner(",");
                courseCatalogMap.forEach((k,v)->{
                    v.getMaterialId();
                    joiner.add(v.getMaterialId().toString());
                });
                //获取播放记录目录下的素材
                Map<BigDecimal, CouMaterial> couMaterialMap = couMaterialBiz.findMaterialByIdsToMap(joiner.toString(),false,setCatalogTeacher);
                courseLearnFlowList.forEach(e->{
                    CourseCatalog courseCatalog = courseCatalogMap.get(e.getCatalogId());
                    if(setCatalogTeacher){
                        if( ObjectUtils.isNotEmpty(courseCatalog)){
                            //把目录关联的老师设置到目录中
                            CouMaterial material = couMaterialMap.get(courseCatalog.getMaterialId());
                            if(ObjectUtils.isNotEmpty(material)){
                                courseCatalog.setTeacher(material.getTeacher());
                            }
                        }
                    }
                    e.setCourseCatalog(courseCatalog);
                });
            }
        }
    }

    /**
     * 处理缺表
     * @param name
     * @param userId
     */
    private void tableError(String name,String userId){
            Map<String,String> tableMap = new HashMap<>();
            tableMap.put(name,userId);
            CreateTableTool.createTable(dataSource,tableMap);
    }


    /**
     * 设置随堂练习
     * @param courseLearnFlows
     */
    private void setPractice(List<CourseLearnFlow> courseLearnFlows){
      //验证是否拥有随堂练习
        for(CourseLearnFlow courseLearnFlow:courseLearnFlows){
            CourseCatalog courseCatalog = courseLearnFlow.getCourseCatalog();
            if (ObjectUtils.isNotEmpty(courseCatalog)&&StringUtils.isNotEmpty(courseCatalog.getQuestionIds())) {
                courseLearnFlow.setPracticeExist(true);
                checkStudyLimit(courseLearnFlow);
            }
        }
    }

    private void checkStudyLimit(CourseLearnFlow courseLearnFlow) {
        //查询已完成学习的前一个节点学习记录
        CoursePlayRecord coursePlayRecord = coursePlayRecordBiz.findOne("userId = "+courseLearnFlow.getUserId()+" and buyCourseId="+courseLearnFlow.getBuyCourseId()+" and courseId="+courseLearnFlow.getCourseId()+" and catalogId="+courseLearnFlow.getCatalogId(),null);

        if(ObjectUtils.isNotEmpty(coursePlayRecord)){//没有学习记录

                //随堂练习总分数
                int practice =  courseLearnFlow.getCourseCatalog().getPractice();
                //用户随堂练习得分
                int _practice = coursePlayRecord.getPractice();
                //课程通过得分率
            double scorePercent =0;
            if(ObjectUtils.isNotEmpty(courseLearnFlow.getCourse())){
                scorePercent = courseLearnFlow.getCourse().getScorePercent();
            }else{
                scorePercent = courseLearnFlow.getBuyCourse().getScorePercent();
            }
            //得分通过率
             courseLearnFlow.setScorePercent(scorePercent);
                //用户得分率
                double _scorePercent =  new Double(_practice) / new Double(practice) * 100D;
                //如果通过
                if(_scorePercent>= scorePercent){
                     courseLearnFlow.setPass(true);
                }
                //获取最后一次得答题记录
            Map  condition = new HashMap();
            condition.put("userId",courseLearnFlow.getUserId());
            condition.put("courseIds",courseLearnFlow.getBuyCourseId());
            condition.put("catalogId",courseLearnFlow.getCatalogId());
            ExamRecord examRecordPractice = examRecordService.findExamRecordPractice(condition);
            if(ObjectUtils.isNotEmpty(examRecordPractice)){
                courseLearnFlow.setPracticeId(new BigDecimal(examRecordPractice.getId().toString()));
            }else{
                courseLearnFlow.setPracticeId(new BigDecimal(0));
                courseLearnFlow.setPass(false);
            }
         }
        }


}
